package com.example;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

/**
 * @author chenlin
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@MapperScan("com.example.demo.dao")
@ComponentScan(basePackages = {"com.example.*"})
//@EnableWebMvc
public class    DemoApplication extends SpringBootServletInitializer {
    protected static final Logger logger = LoggerFactory.getLogger(DemoApplication.class);
    public static void main(String[] args) {
        logger.info("启动");
        SpringApplication.run(DemoApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // TODO Auto-generated method stub
        return builder.sources(DemoApplication.class);
    }
//    /**
//     * 添加对jsp支持
//     *
//     * @return
//     */
//    @Bean
//    public ViewResolver getJspViewResolver() {
//        InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
//        internalResourceViewResolver.setPrefix("/WEB-INF/");
//        internalResourceViewResolver.setSuffix(".jsp");
//        internalResourceViewResolver.setOrder(0);
//        return internalResourceViewResolver;
//    }
//
//    /**
//     * 添加对Freemarker支持
//     *
//     * @return
//     */
//    @Bean
//    public FreeMarkerViewResolver getFreeMarkerViewResolver() {
//        FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver();
//        freeMarkerViewResolver.setCache(false);
//        freeMarkerViewResolver.setPrefix("/WEB-INF/");
//        freeMarkerViewResolver.setSuffix(".html");
//        freeMarkerViewResolver.setRequestContextAttribute("request");
//        freeMarkerViewResolver.setOrder(1);
//        freeMarkerViewResolver.setContentType("text/html;charset=UTF-8");
//        return freeMarkerViewResolver;
//
//    }
}
